package cn.tedu.announcement.management.controller;

import cn.tedu.announcement.management.pojo.param.NoticeParam;
import cn.tedu.announcement.management.pojo.vo.NoticeVO;
import cn.tedu.announcement.management.service.IAnnouncementService;
import cn.tedu.common.web.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/announcements/")
public class AnnouncementController {
    @Autowired
    private IAnnouncementService announcementService;

    @PostMapping("add-new")
    public JsonResult addNew(@RequestBody NoticeParam noticeParam){
        announcementService.addNew(noticeParam);
        return JsonResult.ok();
    }

    @GetMapping("")
    public JsonResult listAll(){
        List<NoticeVO> list = announcementService.listAll();
        return JsonResult.ok(list);
    }

    @PostMapping("{announcement_id}/delete")
    public JsonResult deleteById(@PathVariable Long announcement_id){
        announcementService.deleteById(announcement_id);
        return JsonResult.ok();
    }

}
